'''
Module to read fasta files.
'''

# reads fasta returns dictionary.
def read_fasta_dict(fasta_file):
	
	# declare data.
	res = {}
	
	# loop over file.
	fin = open(fasta_file, "rb")
	first = True
	for line in fin:
		# check if we start new entry.
		if line[0] == ">":
			# tally.
			if first == False:
				# save entry.
				res[head] = seq
				
			else:
				first = False
				
			# clear.
			head = line.strip().replace(">","")
			seq = ""
			continue
		
		
		# get only seq.
		seq += line.strip()
		
	# save last and close.
	res[head] = seq
	fin.close()

	# return result.
	return res
	
